// =======================================================================
// 
//       Filename:  page.hpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  27.03.2010 19:13:52
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
//        Company:  -
// 
// =======================================================================


#ifndef  PAGE_INC
#define  PAGE_INC
#include <iostream>
#include <map>
#include <vector>
#include <yaml.h>
#include <boost/filesystem.hpp>

namespace webplodder {
    // Forward declaration
    namespace navigation {
        class Node;
    }

    /**
     * @brief Represents a *.page file which holds parsed
     * variables and input/output file path.
     */
    class Page : public std::map<std::string,std::string>
    {
    public:
        /**
         * @brief Constructs page file
         * @param[in] sourcePath The input file path.
         * @param[out] outputPath The output file path.
         */
        Page(const boost::filesystem::path& sourcePath,
             const boost::filesystem::path& outputPath);

        /**
         * @brief Parses the underlaying yaml file.
         */
        void parse();

        /**
         * @brief Installs a navigation. Means that it transforms
         * absolute paths to relative paths.
         */
        void installNavigation(const std::vector<navigation::Node>&
                                                        navi);

        /**
         * @brief Returns the path to the source file.
         */
        boost::filesystem::path sourcePath() const;

        /**
         * @brief Returns the path to output file.
         */
        boost::filesystem::path outputPath() const;

        /**
         * @brief Returns the installed navigation.
         * If no navigation was installed. It returns an empty
         * vector.
         */
        std::vector<navigation::Node>& navigation();

    private:
        boost::filesystem::path mSourcePath;
        boost::filesystem::path mOutputPath;
        std::vector<navigation::Node> mNavigation;
    };
}
#endif   // ----- #ifndef PAGE_INC  -----
